package com.hfzy.ihk.web.callhistoryold.jobs.demo;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.hfzy.ihk.web.callhistoryold.biz.CallHistoryOldBiz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

@Slf4j
@Component("simpleDemoJob")
public class SimpleDemoJob implements SimpleJob {

    @Autowired
    CallHistoryOldBiz callHistoryOldBiz;

    @Autowired
    StringRedisTemplate stringRedisTemplate;



    public void execute(ShardingContext context) {
        int item  = context.getShardingItem();
        Long id = stringRedisTemplate.opsForValue().increment("testId",1L);
        if(id != null) {
            log.info("处理id为:" + id + "的数据");
            log.info("开始:执行buildDatasFromHBase，startUserId:" + id + ",limit:100");
            long start = System.currentTimeMillis();

            callHistoryOldBiz.buildDatasFromHBase(id.intValue(), 100);

            log.info("结束:执行buildDatasFromHBase，startUserId:" + id.intValue() + ",limit:" + 100 + ",耗时:" + (System.currentTimeMillis() - start));
        }
    }
}
